<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">
 <f:view encoding="UTF-8" contentType="text/html">
<h:head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
	<title>Постерминалы</title> 
</h:head>
<h:body>
	<h:form id="posListView">
		<style>
			.ui-widget, .ui-widget .ui-widget { font-size: 90% !important;} 
		</style>

		<ui:remove>
		<!-- wait version 3.5.7+
		<p:growl id="growl" showDetail="true" />
		<p:commandButton value="Add Posterminal" icon="ui-icon-extlink" actionListener="#{posterminalBean.addPosterminal}">  
        	<p:ajax event="dialogReturn" listener="#{posterminalBean.onPosterminalAdd}" update="growl" />  
    	</p:commandButton>		
		 -->
		 </ui:remove>

		<p:commandButton id="addPosterminal" value="Добавить постерминал" onclick="posListView:addposterminaldialog.show();" type="button" update=" posListView:dataTable"/>
		
		<p:dialog id="addPosterminalDialog" header="Добавление постерминала" widgetVar="addposterminaldialog" modal="true" resizable="false">  
    		<h:outputText value="Введите данные постерминала" />
    		<h:panelGrid columns="3" cellpadding="5">
    			
    			<h:outputText value="Производитель"/>
	            <p:selectOneMenu id="newPosProducerDDL" value="#{posterminalBean.posterminalProducer}" style="width:100%" required="false">
					<f:converter converterId="posterminalProducerConverter" />
					<f:selectItems value="#{posterminalBean.producerList4DDL}" var="producer" itemLabel="#{producer.producerName}"/>
                	<p:ajax update=":posListView:newPosModelDDL" listener="#{posterminalBean.fillPossbileModelList}"/>
                </p:selectOneMenu> <br/>
                
                <h:outputText value="Модель"/>
	            <p:selectOneMenu id="newPosModelDDL" value="#{posterminalBean.posterminalModel}" style="width:100%" required="false">
					<f:converter converterId="posterminalModelConverter" />
					<f:selectItems value="#{posterminalBean.modelList4DDL}" var="posModel" itemLabel="#{posModel.posterminalModelName}"/>
	            </p:selectOneMenu> 	<br/>		
    			
    			<h:outputText value="Введите серийный номер" />
    			<p:inputText id="newSerialText" value="#{posterminalBean.newPosterminal.serialNumber}" 
    				required="false">
    				<ui:remove> <f:validateLength minimum = "1"/> </ui:remove>
    			</p:inputText> <br/>
    			<ui:remove> <p:message for="newSerialText" display="icon"/> </ui:remove>
    			
    			<h:outputText value="Введите инвентарный номер" /> 
    			<p:inputText value="#{posterminalBean.newPosterminal.inventoryNumber}"/>
	            
    		</h:panelGrid>
    		<f:ajax click="#{posterminalBean.addPosterminal}" update="addPosterminal, dataTable">
    		<p:commandButton id="closeAddPosDlg" value="Добавить постерминал" onmouseup="addposterminaldialog.hide();" oncomplete="posListView:posTableWidget.clearFilters();"
    			update="addPosterminalDialog, dataTable, msg4User" actionListener="#{posterminalBean.addPosterminal}">	
    		</p:commandButton>
    		</f:ajax>
		</p:dialog>  

		<p:dataTable id="dataTable" var="pos" value="#{posterminalBean.posList}" widgetVar="posTableWidget"   
            emptyMessage="No posterminal found with given criteria" filteredValue="#{posterminalBean.filteredPos}">
        
         
       		<p:column id="posProducer" filterBy="#{pos.posterminalModel.posterminalProducer.producerName}"   
                headerText="Производитель" footerText="Производитель"  
                filterMatchMode="contains">  
            	<h:outputText value="#{pos.posterminalModel.posterminalProducer.producerName}" />  
        	</p:column>
        
      		<p:column id="posModel" filterBy="#{pos.posterminalModel.posterminalModelName}"   
                headerText="Модель" footerText="Модель"  
                filterMatchMode="contains">  
            	<h:outputText value="#{pos.posterminalModel.posterminalModelName}" />  
        	</p:column> 
        
        	<p:column id="posSerialNumber" filterBy="#{pos.serialNumber}"   
                headerText="Серийный номер" footerText="Серийный номер"  
                filterMatchMode="contains">  
            	<h:outputText value="#{pos.serialNumber}" />  
        	</p:column>

        	<p:column id="posInventoryNumber" filterBy="#{pos.inventoryNumber}"   
                headerText="Инвентарный номер" footerText="Инвентарный номер"  
                filterMatchMode="contains">  
            	<h:outputText value="#{pos.inventoryNumber}" />  
        	</p:column> 
        
        </p:dataTable>
        <h:outputText id="msg4User" value="#{posterminalBean.message4User}"/>
	</h:form>
</h:body>
</f:view>
</html>
